import {
  type ComponentType,
  type FC,
  type LazyExoticComponent,
  Suspense,
} from 'react';
import LazyLoading from '@/components/LazyLoading';

interface LazyImportProps {
  lazy?: LazyExoticComponent<ComponentType>;
}

export const LazyImport: FC<LazyImportProps> = ({ lazy }) => {
  const Component = lazy ? lazy : () => null;
  return (
    <Suspense fallback={<LazyLoading />}>
      <Component />
    </Suspense>
  );
};
